/*
 * Copyright (c) 2010, Nikolaus Moll
 * All rights reserved.
 */
package net.miblounge.gradecalculator.core.student;

public final class ExaminationResultType {
	
	public static final ExaminationResultType PASSED = new ExaminationResultType("PASSED", 0);
	private static ExaminationResultType[] types = new ExaminationResultType[] { 
		PASSED, 
		new ExaminationResultType("ESTIMATED", 1), 
		new ExaminationResultType("BESTCASE", 2),
		new ExaminationResultType("WORSTCASE", 3),
	};
	
	private String name;
	private int ordinal;
	

	
	private ExaminationResultType(final String name, final int ordinal)
	{
		this.name = name;
		this.ordinal = ordinal;
	}

	public int ordinal() {
		return ordinal;
	}

	public String getName() {
		return name;
	}

	@Override
	public String toString() {
		return getName();
	}
	
	public static ExaminationResultType[] values() {
		return types;
	}

	public static ExaminationResultType valueOf(final String type) {
		for (ExaminationResultType rt : types) {
			if (rt.name.equals(type)) {
				return rt;
			}
		}

		return null;
	}
}
